/*******************************************
 *                                         *
 *******************************************/

#include "GameBoard.h"

GameBoard::GameBoard (void)
{
	this->Background = NULL;
	this->GameTiles = NULL;
	for (int i = 0; i <= BOARD_HEIGHT; i++)
	{
		for (int j = 0; j <= BOARD_WIDTH; j++)
		{
			this->Board[i][j] = '*';
		}
	}
}

GameBoard::GameBoard (LPDIRECT3DDEVICE9 DrawDevice, float ScreenWidth, float ScreenHeight)
{
	this->Background = NULL;
	this->GameTiles = NULL;
	this->Init(DrawDevice, ScreenWidth, ScreenHeight);
}

GameBoard::~GameBoard (void)
{
	if (this->Background)
		delete this->Background;
}

BOOL GameBoard::Init (LPDIRECT3DDEVICE9 DrawDevice, float ScreenWidth, float ScreenHeight)
{
	BOOL Success = TRUE;

	if (!(this->Background = new Sprite(DrawDevice, ScreenWidth, ScreenHeight, 1.0f)))
		Success = FALSE;
	else
		this->Background->LoadTexture(L"GameBoard.png");
	if ((Success) && (!(this->GameTiles = new Tiles(DrawDevice))))
		Success = FALSE;

	return Success;
}

BOOL GameBoard::Logic (GameKeyboard & Keyboard, GameState & State)
{
	BOOL Success = TRUE;
	
	Keyboard.Update();
	if (Keyboard.IsKeyDown(DIK_ESCAPE))
		Success = FALSE;
	
	return Success;
}

void GameBoard::Render (void)
{
	this->Background->Draw();
}